﻿using BCDto.Common.News.NewsContentComment;
using BCService.Common.News.NewsContentCommentService;
using Microsoft.AspNetCore.Mvc;

namespace BCTMSRESTful.Controllers
{
    /// <summary>
    /// 新闻评论控制器（开放）
    /// </summary>
    [Route("api/v1/[controller]")]
    [ApiController]
    public class NewsContentCommentController : BCTMSRESTfulAPIController
    {
        private readonly INewsContentCommentService newsContentCommentService;

        public NewsContentCommentController(INewsContentCommentService newsContentCommentService)
        {
            this.newsContentCommentService = newsContentCommentService;
        }
        
        /// <summary>
        /// 新闻评论点赞或取消点赞。
        /// </summary>
        /// <param name="newsContentCommentId">新闻评论Id。</param>
        /// <param name="isAdd">true 点赞，false 取消点赞</param>
        /// <response code="200">已生成的手机验证码信息。</response>
        /// <returns></returns>
        [HttpPut("[action]/{news_content_comment_id}")]
        [ProducesResponseType(typeof(NewsContentCommentDto), 200)]
        public IActionResult Like([FromRoute(Name = "news_content_comment_id")]long newsContentCommentId,
            [FromQuery(Name = "is_add")]bool isAdd)
        {
            var result = this.newsContentCommentService.UpdateCommentLikeCount(newsContentCommentId, isAdd);
            return Ok(result);
        }
    }
}
